#include<bits/stdc++.h>
using namespace std;
int n,m,T,V,l,cnt,tota,totb,totc,maxn,minn,p[100005];
double maxa,minb;
double a[100005],b[100005],c[100005];
int read(){
	int a;
	scanf("%d",&a);
	return a;
}
void work(double d,double v,double aa){
	if(aa > 0 && v >= V){
		a[++tota] = double(d);
	}
	if(aa > 0 && v < V){
		double t = (V - v) / aa;
		double x = ((V + v) / 2) * t;
		if(x < l-d){
			a[++tota] = double(max(double(x+d),double(1)));
		}else{
			cnt++;
		}
		cout << d << " "<<v << " " << aa << " "<<t<<" "<<x + d << endl;
	
	}
	if(a == 0){
		if(v <= V);
		else{
			a[++tota] = double(d);
		}
	}
	if(aa < 0 && v > V){
		c[++totc] = double(d);
		double t = (v - V) / -aa;
		double x = (v + V) /2 *t;
		if(x + d < l){
			b[++totb] = double(x + d);
		}
		else b[++totb] = double(l);
//		cout << d << " "<<v << " " << aa << " "<<t<<" "<<x + d << endl;
	}
	if(aa < 0 && v <= V);
	
}
signed main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	T = read();
	while(T--){
		memset(p,0,sizeof(p));
		memset(a,0,sizeof(a));
		memset(b,0,sizeof(b));
		memset(c,0,sizeof(c));
		n = read(),m = read(),l = read(),V = read();
		minn = l+1;
		minb = l+1;
		for(int i = 1;i <= n;i++){
			int x,y,z;
			cin >> x >> y >> z;
			work(x,y,z);
		}
		for(int i = 1;i <= m;i++){
			p[i] = read();
			maxn = max(p[i],maxn);
			minn = min(p[i],minn);
		}
		for(int i = 1;i <= tota;i++){
			if(a[i] < double(maxn)){
				cnt++;
//				maxa = max(a[i],maxa);
			}	
		}
		for(int i = 1;i <= totb;i++){
			if(b[i] > double(minn))
				cnt++;
//				minb = min(b[i],minb);
		}
		cout << cnt << " ";
		for(int i = 1;i <= tota;i++){
			if(a[i] > double(maxn)){
				maxa = max(a[i],maxa);
			}	
		}
		for(int i = 1;i <= totc;i++){
			if(c[i] > double(maxn))
				maxa = max(c[i],maxa);
//			cout << c[i] << endl;
		}
		for(int i = 1;i <= totb;i++){
			if(b[i] < double(minn)){
				minb = min(b[i],minb);
			}	
		}
		int ans = 2;
//		cout << maxa << " " << minb << endl;
		for(int i = 1;i <= m;i++){
			if(double(p[i]) > maxa && double(p[i]) < minb)
				ans = 1;
		}
		cout << m - ans << endl;
	}
	return 0;
}
